package com.gd.data.platform.controller.ext;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gd.data.platform.dto.ApiResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * 系统扩展API控制器
 * 提供系统状态和健康检查接口
 * 
 * @author gd-data-platform
 * @since 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/system")
@Api(tags = "系统扩展API")
public class SystemController {

    /**
     * 系统健康检查
     */
    @GetMapping("/health")
    @ApiOperation("系统健康检查")
    public ApiResponse<Map<String, Object>> healthCheck() {
        try {
            Map<String, Object> health = new HashMap<>();
            health.put("status", "UP");
            health.put("timestamp", LocalDateTime.now());
            health.put("version", "1.0.0");
            health.put("description", "开放广东数据开放平台");

            return ApiResponse.success(health);
        } catch (Exception e) {
            log.error("健康检查失败", e);
            return ApiResponse.error("健康检查失败：" + e.getMessage());
        }
    }

    /**
     * 获取系统信息
     */
    @GetMapping("/info")
    @ApiOperation("获取系统信息")
    public ApiResponse<Map<String, Object>> getSystemInfo() {
        try {
            Map<String, Object> info = new HashMap<>();
            info.put("applicationName", "开放广东数据开放平台");
            info.put("version", "1.0.0");
            info.put("description", "大数据架构设计 - 实时监控和离线分析平台");
            info.put("startTime", LocalDateTime.now());
            info.put("architecture", "SpringBoot + MyBatisPlus + Kafka + Flink + ClickHouse");

            return ApiResponse.success(info);
        } catch (Exception e) {
            log.error("获取系统信息失败", e);
            return ApiResponse.error("获取系统信息失败：" + e.getMessage());
        }
    }
}
